import os

from config import ALLOWED_EXTENSIONS


def make_dir(make_dir_path):
    path = make_dir_path.strip()
    if not os.path.exists(path):
        os.makedirs(path)


def file_suffix(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1].lower()


def allowed_file(filename):
    return file_suffix(filename) in ALLOWED_EXTENSIONS


def is_none(paraname, para):
    return paraname not in para or para[paraname] == '' or para[paraname] is None


def get_value(paraname, para):
    return None if paraname not in para or para[paraname] == '' or para[paraname] is None else para[paraname]
